﻿Imports Microsoft.Office.Tools.Ribbon

Public Class Ribbon1

    Dim proxy As New PizzaService.Service1Client

    Private Sub Ribbon1_Load() Handles MyBase.Load
        Dim customers = proxy.GetAllCustomers()

        For Each c In customers
            Dim item As New Microsoft.Office.Tools.Ribbon.RibbonDropDownItem
            item.Label = c.Name
            item.Tag = c
            Me.ddCust.Items.Add(item)
        Next
    End Sub

    Private Sub btnOrders_Click() Handles btnOrders.Click
        If Me.ddCust.SelectedItem IsNot Nothing Then
            Dim customer = CType(Me.ddCust.SelectedItem.Tag, PizzaService.Customer)

            Dim orders = proxy.GetOpenOrdersByCustomerID(customer.Customer_ID)
            Dim sheet = CType(Globals.ThisAddIn.Application.ActiveSheet, Excel.Worksheet)

            sheet.Cells(1, 1).Value = "Open Orders"

            For i = 0 To orders.Count - 1
                Dim o = orders(i)
                Dim row = i + 2
                sheet.Cells(row, 1).value = o.DeliverByDate
            Next

        End If
    End Sub


End Class
